<!DOCTYPE html>
<html>
<head>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" charset="UTF-8">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <style>
        p {margin: 0px 0px 0px 0px}
    </style>
    <title>潜伏者资讯</title>
</head>
<body>

<div style="border:0px solid;width:530px;height:auto;overflow-y:auto; overflow-x:auto;" >
<div id="broadcast_content_div">
    <span class="glyphicon glyphicon-triangle-bottom"></span>
    <font size="4">广播</font>
    <div id="broadcast_content" style="margin-left: 20px;"> </div>
</div>
    <br/>
    <span class="glyphicon glyphicon-triangle-bottom"></span>
    <font size="4">资讯&通知</font>
    <div id="content" style="margin-left: 20px;"> </div>
</div>

<script>
     $("#broadcast_content_div").hide();
    infoAlertList = [];

    function getMore() {
        var htmlStr = "";
        for (var i = 0; i < infoAlertList.length; i++) {
            htmlStr += infoAlertList[i]["message"].replace("<br>", "").replace("<div>", "").replace("</div>", "");
        }
        htmlStr += "<a style='color:black' href='#' onclick='hide()'>收起</a>";
        $("#content").html(htmlStr);
    }

    function hide() {
        var htmlStr = "";
        var infoAlertListLength = Math.min(infoAlertList.length,3);
        for (var i = 0; i < infoAlertListLength; i++) {
            htmlStr += infoAlertList[i]["message"].replace("<br>", "").replace("<div>", "").replace("</div>", "");
        }
        htmlStr += "<a style='color:black' href='#' onclick='getMore()'>查看更多</a>";
        $("#content").html(htmlStr);
    }

    function loadhtml(result) {
        if ($.type(result) == "string") {
            result = JSON.parse(result);
        }
        var htmlStr = "";
        infoAlertList = result.infoAlertList;
        var broadcast_info = result.broadcast_info;
        if (broadcast_info != ""){
            $("#broadcast_content_div").show();
            $("#broadcast_content").html(broadcast_info);
        }
        var infoAlertListLength = Math.min(infoAlertList.length,3);
        for (var i = 0; i < infoAlertListLength; i++) {
            htmlStr += infoAlertList[i]["message"].replace("<br>", "").replace("<div>", "").replace("</div>", "");
        }
        htmlStr += "<a style='color:black' href='#' onclick='getMore()'>查看更多</a>";
        $("#content").html(htmlStr);
    }

    function adddiv(div) {
        if ($.type(div) == "string") {
            div = JSON.parse(div);
        }
        infoAlertList = [div].concat(infoAlertList);
        hide();
    }

    (function(){
        $.ajax({
            url:"/stockIncubatorData",
            async:true,
            success: loadhtml
        });
    })();

</script>
</body>
</html>